package com.bwie.user.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.bwie.user.entity.ComeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.user.entity.TypeEntity;
import com.bwie.user.service.TypeService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author ShuangzhiZhao
 * @email 466505908@qq.com
 * @date 2022-02-17 08:56:51
 */
@RestController
@RequestMapping("user/type")
public class TypeController {
    @Autowired
    private TypeService typeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = typeService.queryPage(params);

        return R.ok().put("page", page);
    }
    @RequestMapping("/typeList")
    public List<TypeEntity> typeList(){
        return typeService.list();
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{tid}")
    public R info(@PathVariable("tid") Integer tid){
		TypeEntity type = typeService.getById(tid);

        return R.ok().put("type", type);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TypeEntity type){
		typeService.save(type);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TypeEntity type){
		typeService.updateById(type);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] tids){
		typeService.removeByIds(Arrays.asList(tids));

        return R.ok();
    }

}
